class Solution:
    def getHint(self, secret: str, guess: str) -> str:
        bulls = 0
        cows = 0
        secretDic = {}
        guessDic = {}
        minLen = min(len(secret), len(guess))
        for i in range(minLen):
            if secret[i] == guess[i]:
                bulls = bulls + 1
            else:
               if secret[i] not in secretDic:
                   secretDic[secret[i]] = 0
               secretDic[secret[i]] += 1
               if guess[i] not in guessDic:
                   guessDic[guess[i]] = 0
               guessDic[guess[i]] += 1
        for i in range(minLen, len(secret)):
            if secret[i] not in secretDic:
                secretDic[secret[i]] = 0
            secretDic[secret[i]] += 1
        for i in range(minLen, len(guess)):
            if guess[i] not in guessDic:
                guessDic[guess[i]] = 0
            guessDic[guess[i]] += 1
        for key in guessDic:
            if key in secretDic:
                cows += min(guessDic[key], secretDic[key])
        return str(bulls) + 'A' + str(cows) + 'B'

if __name__ == '__main__':
    so = Solution()
    secret = "1123"
    guess = "0111"
    r= so.getHint(secret, guess)
    print(r)
